#include "parallel.h"

void pi_parallel_for () {
    double pi, sum=0.0 ;
    step = 1.0 / (double) num_steps;
    #pragma omp parallel 
    {
        double x;
        #pragma omp for reduction(+:sum)
        for (int i=1;i<= num_steps; i++){
            x = (i-0.5)*step; 
            sum = sum + 4.0 / (1.0+x*x);
        } 
    }
    pi = step * sum; 
    printf("pi = %.20lf\n", pi);
}

int main(int argc, char **argv){
    for(int i = 0; i < 9; i++){
        double start, end; 
        int thread = threads[i]; 
        omp_set_num_threads(thread);
        start = omp_get_wtime(); 
        pi_parallel_for();
        end = omp_get_wtime(); 
        printf("thread %d Work took %f seconds\n",thread, end - start);
    }
}